﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Reflection;

namespace DynamicUIFramework
{
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
    public class PropertyActionAttribute : Attribute
    {
        public PropertyActionAttribute(string name)
        {
            this.PropertyName = name;
        }
        public string PropertyName { get; set; }

        public string DisplayName { get { return PropertyName; } }

        public void SetProperty(object obj, object value)
        {
            PropertyInfo pi = obj.GetType().GetProperty(PropertyName);
            pi.SetValue(obj, value, null);
        }

        public object GetProperty(object obj)
        {
            PropertyInfo pi = obj.GetType().GetProperty(PropertyName);
            return pi.GetValue(obj, null);
        }
    }
}
